//package com.example.springboottest.config;
//
//import com.amazonaws.ClientConfiguration;
//import com.amazonaws.Protocol;
//import com.amazonaws.auth.AWSStaticCredentialsProvider;
//import com.amazonaws.auth.BasicAWSCredentials;
//import com.amazonaws.client.builder.AwsClientBuilder;
//import com.amazonaws.regions.Regions;
//import com.amazonaws.services.s3.AmazonS3;
//import com.amazonaws.services.s3.AmazonS3ClientBuilder;
//import org.springframework.beans.factory.InitializingBean;
//import org.springframework.beans.factory.annotation.Value;
//import org.springframework.stereotype.Component;
//
//@Component
//public class AwsS3Component implements InitializingBean {
//
//    @Value("${custom.aws.access-key}")
//    private String accessKey;
//
//    @Value("${custom.aws.secret-key}")
//    private String accessSecret;
//
//    @Value("${custom.aws.bucket}")
//    private String bucket;
//
//    @Value("${custom.aws.endpoint}")
//    private String endpoint;
//
//    @Value("${custom.aws.region}")
//    private String region;
//
//    private AmazonS3 client;
//
//
//    @Override
//    public void afterPropertiesSet() {
//        ClientConfiguration config = new ClientConfiguration();
//        config.setProtocol(Protocol.HTTP);
//        config.disableSocketProxy();
//
//        this.client = AmazonS3ClientBuilder
//                .standard()
//                .withClientConfiguration(config)
//                .withCredentials(new AWSStaticCredentialsProvider(new BasicAWSCredentials(accessKey, accessSecret)))
//                .withEndpointConfiguration(new AwsClientBuilder.EndpointConfiguration(endpoint, Regions.US_EAST_1.getName()))
//                .withRegion(region) //Region配置
//                .enablePathStyleAccess()
//                .build();
//    }
//}